{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Install TensorTrade"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Obtaining file:///Users/adam/Desktop/Capfolio/tensortrade\n",
      "Requirement already satisfied, skipping upgrade: numpy==1.16.4 in /usr/local/lib/python3.7/site-packages (from tensortrade==0.2.0b0) (1.16.4)\n",
      "Requirement already satisfied, skipping upgrade: pandas==0.25.0 in /usr/local/lib/python3.7/site-packages (from tensortrade==0.2.0b0) (0.25.0)\n",
      "Requirement already satisfied, skipping upgrade: gym==0.14.0 in /usr/local/lib/python3.7/site-packages (from tensortrade==0.2.0b0) (0.14.0)\n",
      "Requirement already satisfied, skipping upgrade: pyyaml==5.1.2 in /usr/local/lib/python3.7/site-packages (from tensortrade==0.2.0b0) (5.1.2)\n",
      "Requirement already satisfied, skipping upgrade: sympy==1.4 in /usr/local/lib/python3.7/site-packages (from tensortrade==0.2.0b0) (1.4)\n",
      "Requirement already satisfied, skipping upgrade: pytz>=2017.2 in /usr/local/lib/python3.7/site-packages (from pandas==0.25.0->tensortrade==0.2.0b0) (2019.2)\n",
      "Requirement already satisfied, skipping upgrade: python-dateutil>=2.6.1 in /usr/local/Cellar/jupyterlab/1.0.0_5/libexec/vendor/lib/python3.7/site-packages (from pandas==0.25.0->tensortrade==0.2.0b0) (2.7.3)\n",
      "Requirement already satisfied, skipping upgrade: scipy in /usr/local/lib/python3.7/site-packages (from gym==0.14.0->tensortrade==0.2.0b0) (1.4.1)\n",
      "Requirement already satisfied, skipping upgrade: cloudpickle~=1.2.0 in /usr/local/lib/python3.7/site-packages (from gym==0.14.0->tensortrade==0.2.0b0) (1.2.1)\n",
      "Requirement already satisfied, skipping upgrade: pyglet<=1.3.2,>=1.2.0 in /usr/local/lib/python3.7/site-packages (from gym==0.14.0->tensortrade==0.2.0b0) (1.3.2)\n",
      "Requirement already satisfied, skipping upgrade: six in /usr/local/Cellar/jupyterlab/1.0.0_5/libexec/vendor/lib/python3.7/site-packages (from gym==0.14.0->tensortrade==0.2.0b0) (1.11.0)\n",
      "Requirement already satisfied, skipping upgrade: mpmath>=0.19 in /usr/local/lib/python3.7/site-packages (from sympy==1.4->tensortrade==0.2.0b0) (1.1.0)\n",
      "Requirement already satisfied, skipping upgrade: future in /usr/local/lib/python3.7/site-packages (from pyglet<=1.3.2,>=1.2.0->gym==0.14.0->tensortrade==0.2.0b0) (0.17.1)\n",
      "Installing collected packages: tensortrade\n",
      "  Attempting uninstall: tensortrade\n",
      "    Found existing installation: TensorTrade 0.2.0b0\n",
      "    Uninstalling TensorTrade-0.2.0b0:\n",
      "      Successfully uninstalled TensorTrade-0.2.0b0\n",
      "  Running setup.py develop for tensortrade\n",
      "Successfully installed tensortrade\n"
     ]
    }
   ],
   "source": [
    "!python3 -m pip install -e .. -U"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup Data Fetching"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import ssl\n",
    "import pandas as pd\n",
    "\n",
    "ssl._create_default_https_context = ssl._create_unverified_context # Only used if pandas gives a SSLError\n",
    "\n",
    "def fetch(exchange_name, symbol, timeframe):\n",
    "    url = \"https://www.cryptodatadownload.com/cdd/\"\n",
    "    filename = \"{}_{}USD_{}.csv\".format(exchange_name, symbol, timeframe)\n",
    "    volume_column = \"Volume {}\".format(symbol)\n",
    "    new_volume_column = \"Volume_{}\".format(symbol)\n",
    "    \n",
    "    df = pd.read_csv(url + filename, skiprows=1)\n",
    "    df = df[::-1]\n",
    "    df = df.drop([\"Symbol\"], axis=1)\n",
    "    df = df.rename({\"Volume USD\": \"volume\", volume_column: new_volume_column}, axis=1)\n",
    "    df = df.set_index(\"Date\")\n",
    "    df.columns = [symbol + \":\" + name.lower() for name in df.columns]\n",
    "                     \n",
    "    return df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Fetch Historical Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "coinbase_data = pd.concat([\n",
    "    fetch(\"Coinbase\", \"BTC\", \"1h\"),\n",
    "    fetch(\"Coinbase\", \"ETH\", \"1h\")\n",
    "], axis=1)\n",
    "\n",
    "bitstamp_data = pd.concat([\n",
    "    fetch(\"Bitstamp\", \"BTC\", \"1h\"),\n",
    "    fetch(\"Bitstamp\", \"LTC\", \"1h\")\n",
    "], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>BTC:open</th>\n",
       "      <th>BTC:high</th>\n",
       "      <th>BTC:low</th>\n",
       "      <th>BTC:close</th>\n",
       "      <th>BTC:volume_btc</th>\n",
       "      <th>BTC:volume</th>\n",
       "      <th>ETH:open</th>\n",
       "      <th>ETH:high</th>\n",
       "      <th>ETH:low</th>\n",
       "      <th>ETH:close</th>\n",
       "      <th>ETH:volume_eth</th>\n",
       "      <th>ETH:volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-07-01 11-AM</th>\n",
       "      <td>2505.56</td>\n",
       "      <td>2513.38</td>\n",
       "      <td>2495.12</td>\n",
       "      <td>2509.17</td>\n",
       "      <td>114.60</td>\n",
       "      <td>287000.32</td>\n",
       "      <td>279.98</td>\n",
       "      <td>279.99</td>\n",
       "      <td>272.1</td>\n",
       "      <td>275.01</td>\n",
       "      <td>2455.28</td>\n",
       "      <td>679358.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-01 12-PM</th>\n",
       "      <td>2509.17</td>\n",
       "      <td>2512.87</td>\n",
       "      <td>2484.99</td>\n",
       "      <td>2488.43</td>\n",
       "      <td>157.36</td>\n",
       "      <td>393142.50</td>\n",
       "      <td>275.01</td>\n",
       "      <td>275.01</td>\n",
       "      <td>271.0</td>\n",
       "      <td>274.83</td>\n",
       "      <td>3023.14</td>\n",
       "      <td>824362.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-01 01-PM</th>\n",
       "      <td>2488.43</td>\n",
       "      <td>2488.43</td>\n",
       "      <td>2454.40</td>\n",
       "      <td>2454.43</td>\n",
       "      <td>280.28</td>\n",
       "      <td>693254.01</td>\n",
       "      <td>274.83</td>\n",
       "      <td>274.93</td>\n",
       "      <td>265.0</td>\n",
       "      <td>268.79</td>\n",
       "      <td>11204.43</td>\n",
       "      <td>3010787.99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-01 02-PM</th>\n",
       "      <td>2454.43</td>\n",
       "      <td>2473.93</td>\n",
       "      <td>2450.83</td>\n",
       "      <td>2459.35</td>\n",
       "      <td>289.42</td>\n",
       "      <td>712864.80</td>\n",
       "      <td>268.79</td>\n",
       "      <td>269.90</td>\n",
       "      <td>265.0</td>\n",
       "      <td>265.74</td>\n",
       "      <td>6367.05</td>\n",
       "      <td>1702536.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-01 03-PM</th>\n",
       "      <td>2459.35</td>\n",
       "      <td>2475.00</td>\n",
       "      <td>2450.00</td>\n",
       "      <td>2467.83</td>\n",
       "      <td>276.82</td>\n",
       "      <td>682105.41</td>\n",
       "      <td>265.74</td>\n",
       "      <td>272.74</td>\n",
       "      <td>265.0</td>\n",
       "      <td>272.57</td>\n",
       "      <td>5581.66</td>\n",
       "      <td>1500282.55</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  BTC:open  BTC:high  BTC:low  BTC:close  BTC:volume_btc  \\\n",
       "Date                                                                       \n",
       "2017-07-01 11-AM   2505.56   2513.38  2495.12    2509.17          114.60   \n",
       "2017-07-01 12-PM   2509.17   2512.87  2484.99    2488.43          157.36   \n",
       "2017-07-01 01-PM   2488.43   2488.43  2454.40    2454.43          280.28   \n",
       "2017-07-01 02-PM   2454.43   2473.93  2450.83    2459.35          289.42   \n",
       "2017-07-01 03-PM   2459.35   2475.00  2450.00    2467.83          276.82   \n",
       "\n",
       "                  BTC:volume  ETH:open  ETH:high  ETH:low  ETH:close  \\\n",
       "Date                                                                   \n",
       "2017-07-01 11-AM   287000.32    279.98    279.99    272.1     275.01   \n",
       "2017-07-01 12-PM   393142.50    275.01    275.01    271.0     274.83   \n",
       "2017-07-01 01-PM   693254.01    274.83    274.93    265.0     268.79   \n",
       "2017-07-01 02-PM   712864.80    268.79    269.90    265.0     265.74   \n",
       "2017-07-01 03-PM   682105.41    265.74    272.74    265.0     272.57   \n",
       "\n",
       "                  ETH:volume_eth  ETH:volume  \n",
       "Date                                          \n",
       "2017-07-01 11-AM         2455.28   679358.87  \n",
       "2017-07-01 12-PM         3023.14   824362.87  \n",
       "2017-07-01 01-PM        11204.43  3010787.99  \n",
       "2017-07-01 02-PM         6367.05  1702536.85  \n",
       "2017-07-01 03-PM         5581.66  1500282.55  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "coinbase_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>BTC:open</th>\n",
       "      <th>BTC:high</th>\n",
       "      <th>BTC:low</th>\n",
       "      <th>BTC:close</th>\n",
       "      <th>BTC:volume_btc</th>\n",
       "      <th>BTC:volume</th>\n",
       "      <th>LTC:open</th>\n",
       "      <th>LTC:high</th>\n",
       "      <th>LTC:low</th>\n",
       "      <th>LTC:close</th>\n",
       "      <th>LTC:volume_ltc</th>\n",
       "      <th>LTC:volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-07-01 11-AM</th>\n",
       "      <td>2506.50</td>\n",
       "      <td>2510.62</td>\n",
       "      <td>2495.50</td>\n",
       "      <td>2500.00</td>\n",
       "      <td>208.52</td>\n",
       "      <td>521903.70</td>\n",
       "      <td>39.67</td>\n",
       "      <td>39.67</td>\n",
       "      <td>39.32</td>\n",
       "      <td>39.45</td>\n",
       "      <td>49.61</td>\n",
       "      <td>1957.48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-01 12-PM</th>\n",
       "      <td>2500.00</td>\n",
       "      <td>2503.69</td>\n",
       "      <td>2488.25</td>\n",
       "      <td>2495.62</td>\n",
       "      <td>243.08</td>\n",
       "      <td>607308.42</td>\n",
       "      <td>39.45</td>\n",
       "      <td>39.57</td>\n",
       "      <td>39.18</td>\n",
       "      <td>39.57</td>\n",
       "      <td>63.62</td>\n",
       "      <td>2507.48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-01 01-PM</th>\n",
       "      <td>2495.62</td>\n",
       "      <td>2495.62</td>\n",
       "      <td>2433.59</td>\n",
       "      <td>2449.01</td>\n",
       "      <td>579.13</td>\n",
       "      <td>1421546.81</td>\n",
       "      <td>39.57</td>\n",
       "      <td>39.57</td>\n",
       "      <td>38.80</td>\n",
       "      <td>38.90</td>\n",
       "      <td>564.39</td>\n",
       "      <td>22019.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-01 02-PM</th>\n",
       "      <td>2449.01</td>\n",
       "      <td>2480.60</td>\n",
       "      <td>2438.88</td>\n",
       "      <td>2457.90</td>\n",
       "      <td>528.75</td>\n",
       "      <td>1302198.58</td>\n",
       "      <td>38.90</td>\n",
       "      <td>39.08</td>\n",
       "      <td>38.77</td>\n",
       "      <td>39.06</td>\n",
       "      <td>788.53</td>\n",
       "      <td>30732.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-01 03-PM</th>\n",
       "      <td>2457.90</td>\n",
       "      <td>2471.88</td>\n",
       "      <td>2452.10</td>\n",
       "      <td>2466.35</td>\n",
       "      <td>292.31</td>\n",
       "      <td>719666.88</td>\n",
       "      <td>39.06</td>\n",
       "      <td>39.16</td>\n",
       "      <td>38.73</td>\n",
       "      <td>39.15</td>\n",
       "      <td>666.53</td>\n",
       "      <td>26053.18</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  BTC:open  BTC:high  BTC:low  BTC:close  BTC:volume_btc  \\\n",
       "Date                                                                       \n",
       "2017-07-01 11-AM   2506.50   2510.62  2495.50    2500.00          208.52   \n",
       "2017-07-01 12-PM   2500.00   2503.69  2488.25    2495.62          243.08   \n",
       "2017-07-01 01-PM   2495.62   2495.62  2433.59    2449.01          579.13   \n",
       "2017-07-01 02-PM   2449.01   2480.60  2438.88    2457.90          528.75   \n",
       "2017-07-01 03-PM   2457.90   2471.88  2452.10    2466.35          292.31   \n",
       "\n",
       "                  BTC:volume  LTC:open  LTC:high  LTC:low  LTC:close  \\\n",
       "Date                                                                   \n",
       "2017-07-01 11-AM   521903.70     39.67     39.67    39.32      39.45   \n",
       "2017-07-01 12-PM   607308.42     39.45     39.57    39.18      39.57   \n",
       "2017-07-01 01-PM  1421546.81     39.57     39.57    38.80      38.90   \n",
       "2017-07-01 02-PM  1302198.58     38.90     39.08    38.77      39.06   \n",
       "2017-07-01 03-PM   719666.88     39.06     39.16    38.73      39.15   \n",
       "\n",
       "                  LTC:volume_ltc  LTC:volume  \n",
       "Date                                          \n",
       "2017-07-01 11-AM           49.61     1957.48  \n",
       "2017-07-01 12-PM           63.62     2507.48  \n",
       "2017-07-01 01-PM          564.39    22019.12  \n",
       "2017-07-01 02-PM          788.53    30732.98  \n",
       "2017-07-01 03-PM          666.53    26053.18  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bitstamp_data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Define Exchanges\n",
    "\n",
    "An exchange needs a name, an execution service, and streams of price data in order to function properly.\n",
    "\n",
    "The setups supported right now are the simulated execution service using simulated or stochastic data. More execution services will be made available in the future, as well as price streams so that live data and execution can be supported."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from tensortrade.exchanges import Exchange\n",
    "from tensortrade.exchanges.services.execution.simulated import execute_order\n",
    "from tensortrade.data import Stream\n",
    "\n",
    "coinbase = Exchange(\"coinbase\", service=execute_order)(\n",
    "    Stream(\"USD-BTC\", list(coinbase_data['BTC:close'])),\n",
    "    Stream(\"USD-ETH\", list(coinbase_data['ETH:close']))\n",
    ")\n",
    "\n",
    "bitstamp = Exchange(\"bitstamp\", service=execute_order)(\n",
    "    Stream(\"USD-BTC\", list(bitstamp_data['BTC:close'])),\n",
    "    Stream(\"USD-LTC\", list(bitstamp_data['LTC:close']))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now that the exchanges have been defined we can define our features that we would like to include, excluding the prices we have provided for the exchanges."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Define External Data Feed\n",
    "\n",
    "Here we will define the external feed to use whatever data you would like. From financial indicators to datasets that have nothing to do with instrument prices, they will all have to be defined and incorporated into the external data feed provided to the environment. There is also an internal data feed that is used to collect data on all the wallets and the net worth of the portfolio. You can choose to include this or not by using the `use_internal` parameter of the trading environment."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.7/site-packages/ta/wrapper.py:30: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  fillna=fillna)\n",
      "/usr/local/lib/python3.7/site-packages/ta/wrapper.py:33: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  fillna=fillna)\n",
      "/usr/local/lib/python3.7/site-packages/ta/wrapper.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  fillna=fillna)\n",
      "/usr/local/lib/python3.7/site-packages/ta/wrapper.py:41: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  fillna=fillna)\n",
      "/usr/local/lib/python3.7/site-packages/ta/wrapper.py:47: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  fillna=fillna)\n",
      "/usr/local/lib/python3.7/site-packages/ta/trend.py:170: RuntimeWarning: invalid value encountered in double_scalars\n",
      "  dip[i] = 100 * (dip_mio[i]/trs[i])\n",
      "/usr/local/lib/python3.7/site-packages/ta/trend.py:174: RuntimeWarning: invalid value encountered in double_scalars\n",
      "  din[i] = 100 * (din_mio[i]/trs[i])\n"
     ]
    }
   ],
   "source": [
    "import ta\n",
    "\n",
    "from tensortrade.data import DataFeed, Module\n",
    "\n",
    "# Add all features for coinbase bitcoin\n",
    "coinbase_btc = coinbase_data.loc[:, [name.startswith(\"BTC\") for name in coinbase_data.columns]]\n",
    "coinbase_eth = coinbase_data.loc[:, [name.startswith(\"ETH\") for name in coinbase_data.columns]]\n",
    "\n",
    "ta.add_all_ta_features(\n",
    "    coinbase_btc,\n",
    "    colprefix=\"BTC:\",\n",
    "    **{k: \"BTC:\" + k for k in ['open', 'high', 'low', 'close', 'volume']}\n",
    ")\n",
    "\n",
    "\n",
    "with Module(\"coinbase\") as coinbase_ns:\n",
    "    coinbase_nodes = [Stream(name, list(coinbase_btc[name])) for name in coinbase_btc.columns]\n",
    "    coinbase_nodes += [Stream(name, list(coinbase_eth[name])) for name in coinbase_eth.columns]\n",
    "    \n",
    "\n",
    "# Add all features for coinbase ethereum\n",
    "bitstamp_btc = bitstamp_data.loc[:, [name.startswith(\"BTC\") for name in bitstamp_data.columns]]  \n",
    "bitstamp_ltc = bitstamp_data.loc[:, [name.startswith(\"LTC\") for name in bitstamp_data.columns]]\n",
    "\n",
    "ta.add_all_ta_features(\n",
    "    bitstamp_ltc,\n",
    "    colprefix=\"LTC:\",\n",
    "    **{k: \"LTC:\" + k for k in ['open', 'high', 'low', 'close', 'volume']}\n",
    ")\n",
    "\n",
    "with Module(\"bitstamp\") as bitstamp_ns:\n",
    "    bitstamp_nodes = [Stream(name, list(bitstamp_btc[name])) for name in bitstamp_btc.columns]\n",
    "    bitstamp_nodes += [Stream(name, list(bitstamp_ltc[name])) for name in bitstamp_ltc.columns]\n",
    "\n",
    "\n",
    "feed = DataFeed([coinbase_ns, bitstamp_ns])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'coinbase:/BTC:open': 2505.56,\n",
       " 'coinbase:/BTC:high': 2513.38,\n",
       " 'coinbase:/BTC:low': 2495.12,\n",
       " 'coinbase:/BTC:close': 2509.17,\n",
       " 'coinbase:/BTC:volume_btc': 114.6,\n",
       " 'coinbase:/BTC:volume': 287000.32,\n",
       " 'coinbase:/BTC:volume_adi': 471514.15080526855,\n",
       " 'coinbase:/BTC:volume_obv': nan,\n",
       " 'coinbase:/BTC:volume_cmf': 0.5388828039430464,\n",
       " 'coinbase:/BTC:volume_fi': nan,\n",
       " 'coinbase:/BTC:volume_em': nan,\n",
       " 'coinbase:/BTC:volume_vpt': -187654.42529420118,\n",
       " 'coinbase:/BTC:volume_nvi': 1000.0,\n",
       " 'coinbase:/BTC:volatility_atr': 86.38199331252785,\n",
       " 'coinbase:/BTC:volatility_bbh': 2509.17,\n",
       " 'coinbase:/BTC:volatility_bbl': 2509.17,\n",
       " 'coinbase:/BTC:volatility_bbm': 2509.17,\n",
       " 'coinbase:/BTC:volatility_bbhi': 0.0,\n",
       " 'coinbase:/BTC:volatility_bbli': 0.0,\n",
       " 'coinbase:/BTC:volatility_kcc': 2505.89,\n",
       " 'coinbase:/BTC:volatility_kch': 2524.15,\n",
       " 'coinbase:/BTC:volatility_kcl': 2487.6299999999997,\n",
       " 'coinbase:/BTC:volatility_kchi': 0.0,\n",
       " 'coinbase:/BTC:volatility_kcli': 0.0,\n",
       " 'coinbase:/BTC:volatility_dch': 2509.17,\n",
       " 'coinbase:/BTC:volatility_dcl': 2509.17,\n",
       " 'coinbase:/BTC:volatility_dchi': 0.0,\n",
       " 'coinbase:/BTC:volatility_dcli': 0.0,\n",
       " 'coinbase:/BTC:trend_macd': nan,\n",
       " 'coinbase:/BTC:trend_macd_signal': nan,\n",
       " 'coinbase:/BTC:trend_macd_diff': nan,\n",
       " 'coinbase:/BTC:trend_ema_fast': nan,\n",
       " 'coinbase:/BTC:trend_ema_slow': nan,\n",
       " 'coinbase:/BTC:trend_adx': 0.0,\n",
       " 'coinbase:/BTC:trend_adx_pos': 0.0,\n",
       " 'coinbase:/BTC:trend_adx_neg': 0.0,\n",
       " 'coinbase:/BTC:trend_vortex_ind_pos': nan,\n",
       " 'coinbase:/BTC:trend_vortex_ind_neg': nan,\n",
       " 'coinbase:/BTC:trend_vortex_diff': nan,\n",
       " 'coinbase:/BTC:trend_trix': nan,\n",
       " 'coinbase:/BTC:trend_mass_index': 0.0,\n",
       " 'coinbase:/BTC:trend_cci': nan,\n",
       " 'coinbase:/BTC:trend_dpo': 4750.493965939994,\n",
       " 'coinbase:/BTC:trend_kst': -654.3682997212794,\n",
       " 'coinbase:/BTC:trend_kst_sig': -654.3682997212794,\n",
       " 'coinbase:/BTC:trend_kst_diff': 0.0,\n",
       " 'coinbase:/BTC:trend_ichimoku_a': 2504.25,\n",
       " 'coinbase:/BTC:trend_ichimoku_b': 2504.25,\n",
       " 'coinbase:/BTC:trend_visual_ichimoku_a': 7247.04960378494,\n",
       " 'coinbase:/BTC:trend_visual_ichimoku_b': 7236.05851923677,\n",
       " 'coinbase:/BTC:trend_aroon_up': 4.0,\n",
       " 'coinbase:/BTC:trend_aroon_down': 4.0,\n",
       " 'coinbase:/BTC:trend_aroon_ind': 0.0,\n",
       " 'coinbase:/BTC:momentum_rsi': nan,\n",
       " 'coinbase:/BTC:momentum_mfi': nan,\n",
       " 'coinbase:/BTC:momentum_tsi': -100.0,\n",
       " 'coinbase:/BTC:momentum_uo': 0.29488656417987874,\n",
       " 'coinbase:/BTC:momentum_stoch': 76.94414019715232,\n",
       " 'coinbase:/BTC:momentum_stoch_signal': 76.94414019715232,\n",
       " 'coinbase:/BTC:momentum_wr': -23.055859802847678,\n",
       " 'coinbase:/BTC:momentum_ao': 0.0,\n",
       " 'coinbase:/BTC:momentum_kama': nan,\n",
       " 'coinbase:/BTC:others_dr': -65.43682997212794,\n",
       " 'coinbase:/BTC:others_dlr': nan,\n",
       " 'coinbase:/BTC:others_cr': 0.0,\n",
       " 'coinbase:/ETH:open': 279.98,\n",
       " 'coinbase:/ETH:high': 279.99,\n",
       " 'coinbase:/ETH:low': 272.1,\n",
       " 'coinbase:/ETH:close': 275.01,\n",
       " 'coinbase:/ETH:volume_eth': 2455.28,\n",
       " 'coinbase:/ETH:volume': 679358.87,\n",
       " 'bitstamp:/BTC:open': 2506.5,\n",
       " 'bitstamp:/BTC:high': 2510.62,\n",
       " 'bitstamp:/BTC:low': 2495.5,\n",
       " 'bitstamp:/BTC:close': 2500.0,\n",
       " 'bitstamp:/BTC:volume_btc': 208.52,\n",
       " 'bitstamp:/BTC:volume': 521903.7,\n",
       " 'bitstamp:/LTC:open': 39.67,\n",
       " 'bitstamp:/LTC:high': 39.67,\n",
       " 'bitstamp:/LTC:low': 39.32,\n",
       " 'bitstamp:/LTC:close': 39.45,\n",
       " 'bitstamp:/LTC:volume_ltc': 49.61,\n",
       " 'bitstamp:/LTC:volume': 1957.48,\n",
       " 'bitstamp:/LTC:volume_adi': 5689.854874666357,\n",
       " 'bitstamp:/LTC:volume_obv': nan,\n",
       " 'bitstamp:/LTC:volume_cmf': -0.2571428571428455,\n",
       " 'bitstamp:/LTC:volume_fi': nan,\n",
       " 'bitstamp:/LTC:volume_em': nan,\n",
       " 'bitstamp:/LTC:volume_vpt': -894.8193871375488,\n",
       " 'bitstamp:/LTC:volume_nvi': 1000.0,\n",
       " 'bitstamp:/LTC:volatility_atr': 1.6566685515031572,\n",
       " 'bitstamp:/LTC:volatility_bbh': 39.45,\n",
       " 'bitstamp:/LTC:volatility_bbl': 39.45,\n",
       " 'bitstamp:/LTC:volatility_bbm': 39.45,\n",
       " 'bitstamp:/LTC:volatility_bbhi': 0.0,\n",
       " 'bitstamp:/LTC:volatility_bbli': 0.0,\n",
       " 'bitstamp:/LTC:volatility_kcc': 39.480000000000004,\n",
       " 'bitstamp:/LTC:volatility_kch': 39.830000000000005,\n",
       " 'bitstamp:/LTC:volatility_kcl': 39.13,\n",
       " 'bitstamp:/LTC:volatility_kchi': 0.0,\n",
       " 'bitstamp:/LTC:volatility_kcli': 0.0,\n",
       " 'bitstamp:/LTC:volatility_dch': 39.45,\n",
       " 'bitstamp:/LTC:volatility_dcl': 39.45,\n",
       " 'bitstamp:/LTC:volatility_dchi': 0.0,\n",
       " 'bitstamp:/LTC:volatility_dcli': 0.0,\n",
       " 'bitstamp:/LTC:trend_macd': nan,\n",
       " 'bitstamp:/LTC:trend_macd_signal': nan,\n",
       " 'bitstamp:/LTC:trend_macd_diff': nan,\n",
       " 'bitstamp:/LTC:trend_ema_fast': nan,\n",
       " 'bitstamp:/LTC:trend_ema_slow': nan,\n",
       " 'bitstamp:/LTC:trend_adx': 0.0,\n",
       " 'bitstamp:/LTC:trend_adx_pos': 0.0,\n",
       " 'bitstamp:/LTC:trend_adx_neg': 0.0,\n",
       " 'bitstamp:/LTC:trend_vortex_ind_pos': nan,\n",
       " 'bitstamp:/LTC:trend_vortex_ind_neg': nan,\n",
       " 'bitstamp:/LTC:trend_vortex_diff': nan,\n",
       " 'bitstamp:/LTC:trend_trix': nan,\n",
       " 'bitstamp:/LTC:trend_mass_index': 0.0,\n",
       " 'bitstamp:/LTC:trend_cci': nan,\n",
       " 'bitstamp:/LTC:trend_dpo': 47.947129529284254,\n",
       " 'bitstamp:/LTC:trend_kst': -548.612177396725,\n",
       " 'bitstamp:/LTC:trend_kst_sig': -548.612177396725,\n",
       " 'bitstamp:/LTC:trend_kst_diff': 0.0,\n",
       " 'bitstamp:/LTC:trend_ichimoku_a': 39.495000000000005,\n",
       " 'bitstamp:/LTC:trend_ichimoku_b': 39.495000000000005,\n",
       " 'bitstamp:/LTC:trend_visual_ichimoku_a': 87.28460785468594,\n",
       " 'bitstamp:/LTC:trend_visual_ichimoku_b': 87.22703670546106,\n",
       " 'bitstamp:/LTC:trend_aroon_up': 4.0,\n",
       " 'bitstamp:/LTC:trend_aroon_down': 4.0,\n",
       " 'bitstamp:/LTC:trend_aroon_ind': 0.0,\n",
       " 'bitstamp:/LTC:momentum_rsi': nan,\n",
       " 'bitstamp:/LTC:momentum_mfi': nan,\n",
       " 'bitstamp:/LTC:momentum_tsi': -100.0,\n",
       " 'bitstamp:/LTC:momentum_uo': 0.27039883885084753,\n",
       " 'bitstamp:/LTC:momentum_stoch': 37.14285714285772,\n",
       " 'bitstamp:/LTC:momentum_stoch_signal': 37.14285714285772,\n",
       " 'bitstamp:/LTC:momentum_wr': -62.85714285714228,\n",
       " 'bitstamp:/LTC:momentum_ao': 0.0,\n",
       " 'bitstamp:/LTC:momentum_kama': nan,\n",
       " 'bitstamp:/LTC:others_dr': -54.861217739672504,\n",
       " 'bitstamp:/LTC:others_dlr': nan,\n",
       " 'bitstamp:/LTC:others_cr': 0.0}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "feed.next()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Portfolio\n",
    "\n",
    "Make the portfolio using the any combinations of exchanges and intruments that the exchange supports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "from tensortrade.instruments import USD, BTC, ETH, LTC\n",
    "from tensortrade.wallets import Wallet, Portfolio\n",
    "\n",
    "portfolio = Portfolio(USD, [\n",
    "    Wallet(coinbase, 10000 * USD),\n",
    "    Wallet(coinbase, 10 * BTC),\n",
    "    Wallet(coinbase, 5 * ETH),\n",
    "    Wallet(bitstamp, 1000 * USD),\n",
    "    Wallet(bitstamp, 5 * BTC),\n",
    "    Wallet(bitstamp, 3 * LTC),\n",
    "])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Environment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "from tensortrade.environments import TradingEnvironment\n",
    "\n",
    "env = TradingEnvironment(\n",
    "    feed=feed,\n",
    "    portfolio=portfolio,\n",
    "    action_scheme='managed-risk',\n",
    "    reward_scheme='simple',\n",
    "    window_size=15,\n",
    "    enable_logger=False\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'coinbase:/BTC:trend_macd_diff': nan,\n",
       " 'coinbase:/BTC:trend_ema_fast': nan,\n",
       " 'coinbase:/BTC:trend_ema_slow': nan,\n",
       " 'bitstamp:/LTC:volatility_kcc': 39.480000000000004,\n",
       " 'bitstamp:/BTC:/locked': 0,\n",
       " 'coinbase:/BTC:close': 2509.17,\n",
       " 'coinbase:/BTC:trend_adx': 0.0,\n",
       " 'bitstamp:/BTC:volume_btc': 208.52,\n",
       " 'bitstamp:/BTC:/total': 5,\n",
       " 'bitstamp:/USD-BTC': 2500.0,\n",
       " 'coinbase:/BTC:trend_adx_pos': 0.0,\n",
       " 'bitstamp:/LTC:momentum_mfi': nan,\n",
       " 'bitstamp:/BTC:/worth': 12500.0,\n",
       " 'coinbase:/BTC:volatility_bbh': 2509.17,\n",
       " 'coinbase:/USD-ETH': 275.01,\n",
       " 'coinbase:/BTC:trend_macd_signal': nan,\n",
       " 'coinbase:/BTC:trend_adx_neg': 0.0,\n",
       " 'bitstamp:/LTC:volume_nvi': 1000.0,\n",
       " 'coinbase:/BTC:trend_vortex_ind_pos': nan,\n",
       " 'coinbase:/BTC:volatility_dcl': 2509.17,\n",
       " 'bitstamp:/LTC:volume_em': nan,\n",
       " 'coinbase:/BTC:volume_nvi': 1000.0,\n",
       " 'coinbase:/BTC:trend_vortex_ind_neg': nan,\n",
       " 'bitstamp:/LTC:volatility_atr': 1.6566685515031572,\n",
       " 'bitstamp:/USD-LTC': 39.45,\n",
       " 'coinbase:/BTC:trend_macd': nan,\n",
       " 'coinbase:/BTC:trend_vortex_diff': nan,\n",
       " 'bitstamp:/LTC:volatility_kchi': 0.0,\n",
       " 'coinbase:/USD-BTC': 2509.17,\n",
       " 'bitstamp:/LTC:/free': 3,\n",
       " 'coinbase:/BTC:volume_btc': 114.6,\n",
       " 'coinbase:/BTC:trend_trix': nan,\n",
       " 'bitstamp:/LTC:momentum_stoch': 37.14285714285772,\n",
       " 'bitstamp:/LTC:/locked': 0,\n",
       " 'coinbase:/BTC:volatility_bbm': 2509.17,\n",
       " 'bitstamp:/LTC:volatility_kch': 39.830000000000005,\n",
       " 'coinbase:/BTC:trend_mass_index': 0.0,\n",
       " 'bitstamp:/LTC:volatility_bbli': 0.0,\n",
       " 'coinbase:/BTC:/total': 10,\n",
       " 'bitstamp:/LTC:/total': 3,\n",
       " 'coinbase:/BTC:volume_vpt': -187654.42529420118,\n",
       " 'coinbase:/BTC:trend_cci': nan,\n",
       " 'bitstamp:/LTC:/worth': 118.35000000000001,\n",
       " 'coinbase:/BTC:volatility_bbli': 0.0,\n",
       " 'bitstamp:/BTC:low': 2495.5,\n",
       " 'bitstamp:/LTC:volume_obv': nan,\n",
       " 'coinbase:/BTC:trend_dpo': 4750.493965939994,\n",
       " 'net_worth': 50085.1,\n",
       " 'bitstamp:/LTC:volatility_bbhi': 0.0,\n",
       " 'coinbase:/BTC:volume_cmf': 0.5388828039430464,\n",
       " 'coinbase:/BTC:trend_kst': -654.3682997212794,\n",
       " 'bitstamp:/LTC:volatility_kcl': 39.13,\n",
       " 'bitstamp:/LTC:trend_aroon_ind': 0.0,\n",
       " 'bitstamp:/LTC:volume_fi': nan,\n",
       " 'coinbase:/BTC:volume_fi': nan,\n",
       " 'coinbase:/BTC:trend_kst_sig': -654.3682997212794,\n",
       " 'bitstamp:/LTC:volume_cmf': -0.2571428571428455,\n",
       " 'coinbase:/BTC:trend_kst_diff': 0.0,\n",
       " 'coinbase:/BTC:volatility_dch': 2509.17,\n",
       " 'coinbase:/BTC:volatility_atr': 86.38199331252785,\n",
       " 'coinbase:/BTC:trend_ichimoku_a': 2504.25,\n",
       " 'bitstamp:/LTC:volatility_bbh': 39.45,\n",
       " 'bitstamp:/LTC:volume_vpt': -894.8193871375488,\n",
       " 'bitstamp:/LTC:momentum_uo': 0.27039883885084753,\n",
       " 'coinbase:/BTC:trend_ichimoku_b': 2504.25,\n",
       " 'coinbase:/BTC:low': 2495.12,\n",
       " 'coinbase:/BTC:volatility_bbhi': 0.0,\n",
       " 'bitstamp:/LTC:volatility_bbm': 39.45,\n",
       " 'bitstamp:/LTC:trend_visual_ichimoku_a': 87.28460785468594,\n",
       " 'coinbase:/BTC:volatility_dcli': 0.0,\n",
       " 'coinbase:/BTC:trend_visual_ichimoku_a': 7247.04960378494,\n",
       " 'bitstamp:/LTC:trend_visual_ichimoku_b': 87.22703670546106,\n",
       " 'bitstamp:/BTC:close': 2500.0,\n",
       " 'bitstamp:/LTC:volatility_bbl': 39.45,\n",
       " 'coinbase:/BTC:trend_visual_ichimoku_b': 7236.05851923677,\n",
       " 'coinbase:/BTC:volume_em': nan,\n",
       " 'coinbase:/BTC:trend_aroon_up': 4.0,\n",
       " 'coinbase:/BTC:trend_aroon_down': 4.0,\n",
       " 'coinbase:/BTC:volume_adi': 471514.15080526855,\n",
       " 'coinbase:/BTC:trend_aroon_ind': 0.0,\n",
       " 'bitstamp:/LTC:volatility_kcli': 0.0,\n",
       " 'coinbase:/BTC:momentum_rsi': nan,\n",
       " 'coinbase:/BTC:others_cr': 0.0,\n",
       " 'bitstamp:/LTC:volatility_dch': 39.45,\n",
       " 'coinbase:/ETH:open': 279.98,\n",
       " 'coinbase:/BTC:volatility_dchi': 0.0,\n",
       " 'bitstamp:/LTC:volatility_dcl': 39.45,\n",
       " 'bitstamp:/LTC:momentum_stoch_signal': 37.14285714285772,\n",
       " 'coinbase:/ETH:high': 279.99,\n",
       " 'bitstamp:/LTC:momentum_rsi': nan,\n",
       " 'bitstamp:/LTC:volatility_dchi': 0.0,\n",
       " 'coinbase:/BTC:volume': 287000.32,\n",
       " 'coinbase:/ETH:low': 272.1,\n",
       " 'coinbase:/BTC:volume_obv': nan,\n",
       " 'bitstamp:/LTC:volatility_dcli': 0.0,\n",
       " 'coinbase:/BTC:volatility_kcc': 2505.89,\n",
       " 'coinbase:/ETH:close': 275.01,\n",
       " 'bitstamp:/LTC:trend_macd': nan,\n",
       " 'coinbase:/BTC:volatility_kch': 2524.15,\n",
       " 'coinbase:/ETH:volume_eth': 2455.28,\n",
       " 'coinbase:/BTC:volatility_bbl': 2509.17,\n",
       " 'bitstamp:/LTC:trend_macd_signal': nan,\n",
       " 'coinbase:/BTC:volatility_kcl': 2487.6299999999997,\n",
       " 'coinbase:/ETH:volume': 679358.87,\n",
       " 'bitstamp:/LTC:trend_macd_diff': nan,\n",
       " 'coinbase:/BTC:volatility_kchi': 0.0,\n",
       " 'coinbase:/BTC:open': 2505.56,\n",
       " 'bitstamp:/LTC:trend_ema_fast': nan,\n",
       " 'bitstamp:/LTC:momentum_wr': -62.85714285714228,\n",
       " 'coinbase:/BTC:volatility_kcli': 0.0,\n",
       " 'bitstamp:/LTC:trend_ema_slow': nan,\n",
       " 'bitstamp:/LTC:momentum_tsi': -100.0,\n",
       " 'bitstamp:/LTC:trend_adx': 0.0,\n",
       " 'bitstamp:/LTC:trend_adx_pos': 0.0,\n",
       " 'bitstamp:/LTC:trend_adx_neg': 0.0,\n",
       " 'bitstamp:/LTC:trend_vortex_ind_pos': nan,\n",
       " 'coinbase:/BTC:high': 2513.38,\n",
       " 'bitstamp:/LTC:trend_vortex_ind_neg': nan,\n",
       " 'bitstamp:/LTC:trend_vortex_diff': nan,\n",
       " 'bitstamp:/LTC:trend_trix': nan,\n",
       " 'coinbase:/BTC:/locked': 0,\n",
       " 'bitstamp:/USD:/total': 1000,\n",
       " 'bitstamp:/LTC:trend_mass_index': 0.0,\n",
       " 'bitstamp:/BTC:volume': 521903.7,\n",
       " 'bitstamp:/LTC:trend_cci': nan,\n",
       " 'coinbase:/USD:/total': 10000,\n",
       " 'bitstamp:/LTC:trend_dpo': 47.947129529284254,\n",
       " 'coinbase:/BTC:/free': 10,\n",
       " 'bitstamp:/BTC:/free': 5,\n",
       " 'bitstamp:/USD:/locked': 0,\n",
       " 'bitstamp:/LTC:trend_kst': -548.612177396725,\n",
       " 'coinbase:/USD:/locked': 0,\n",
       " 'bitstamp:/LTC:trend_kst_sig': -548.612177396725,\n",
       " 'coinbase:/USD:/free': 10000,\n",
       " 'bitstamp:/LTC:trend_kst_diff': 0.0,\n",
       " 'coinbase:/BTC:momentum_stoch': 76.94414019715232,\n",
       " 'bitstamp:/LTC:trend_ichimoku_a': 39.495000000000005,\n",
       " 'coinbase:/ETH:/worth': 1375.05,\n",
       " 'bitstamp:/LTC:trend_ichimoku_b': 39.495000000000005,\n",
       " 'bitstamp:/LTC:momentum_ao': 0.0,\n",
       " 'coinbase:/BTC:momentum_tsi': -100.0,\n",
       " 'bitstamp:/BTC:high': 2510.62,\n",
       " 'bitstamp:/LTC:momentum_kama': nan,\n",
       " 'coinbase:/ETH:/free': 5,\n",
       " 'coinbase:/BTC:momentum_ao': 0.0,\n",
       " 'coinbase:/BTC:others_dr': -65.43682997212794,\n",
       " 'bitstamp:/LTC:others_dr': -54.861217739672504,\n",
       " 'coinbase:/BTC:momentum_mfi': nan,\n",
       " 'bitstamp:/LTC:others_dlr': nan,\n",
       " 'bitstamp:/LTC:trend_aroon_down': 4.0,\n",
       " 'bitstamp:/LTC:others_cr': 0.0,\n",
       " 'coinbase:/ETH:/total': 5,\n",
       " 'coinbase:/BTC:momentum_kama': nan,\n",
       " 'bitstamp:/BTC:open': 2506.5,\n",
       " 'bitstamp:/LTC:open': 39.67,\n",
       " 'bitstamp:/LTC:high': 39.67,\n",
       " 'coinbase:/BTC:/worth': 25091.7,\n",
       " 'bitstamp:/LTC:close': 39.45,\n",
       " 'coinbase:/BTC:momentum_wr': -23.055859802847678,\n",
       " 'coinbase:/BTC:others_dlr': nan,\n",
       " 'coinbase:/ETH:/locked': 0,\n",
       " 'coinbase:/BTC:momentum_stoch_signal': 76.94414019715232,\n",
       " 'coinbase:/BTC:momentum_uo': 0.29488656417987874,\n",
       " 'bitstamp:/LTC:trend_aroon_up': 4.0,\n",
       " 'bitstamp:/LTC:volume_ltc': 49.61,\n",
       " 'bitstamp:/LTC:volume_adi': 5689.854874666357,\n",
       " 'bitstamp:/LTC:volume': 1957.48,\n",
       " 'bitstamp:/USD:/free': 1000,\n",
       " 'bitstamp:/LTC:low': 39.32}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "env.feed.next()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
